<?
    class Principio_Model_Account implements PrincipioLab_IDAble
    {
        use PrincipioLab_TCollection;

        private $id;
        private $company_id;
        private $login;
        private $password;
        private $display_name;
        private $short_name;
        private $model_company;


        public function __construct($values)
        {
            if (is_array($values))
            {
                $this->id = intval($values['id']);
                $this->company_id = $values['company_id'];
                $this->login = $values['login'];
                $this->password = $values['password'];
                $this->display_name = $values['display_name'];
                $this->short_name = $values['short_name'];

                $this->model_company = null;
            }
            elseif ($values instanceof Principio_Model_Company)
            {
                $this->id = -1;
                $this->company_id = $values->getID();
                $this->login = "";
                $this->password = "";
                $this->display_name = "";
                $this->short_name = "";

                $this->model_company = $values;
            }
            else
                throw new Exception("Wrong values type.");
        }


        public function _getID() { return $this->id; }


        public static function fromArray(array $values = null)
        {
            return new Principio_Model_Account($values);
        }


        public function getLogin() { return $this->login; }
        public function getPassword() { return $this->password; }
        public function getDisplayName() { return $this->display_name; }
        public function getID() { return $this->id; }
        public function getShortName() { return $this->short_name; }


        public function setLogin($login)
        {
            $this->login = $login;
            return $this;
        }


        public function setPassword($password)
        {
            $this->password = $password;
            return $this;
        }


        public function setDisplayName($display_name)
        {
            $this->display_name = $display_name;
            return $this;
        }


        public function setShortName($short_name)
        {
            $this->short_name = $short_name;
            return $this;
        }


        public function setID($id)
        {
            $this->id = intval($id);
            return $this;
        }


        public function getModelCompany()
        {
            if (is_null($this->model_company))
                $this->model_company = Principio_Model_Company_AbstractMapper::fetch($this->company_id);

            return $this->model_company;
        }


        public function add() { return Principio_Model_AccountMapper::save($this); }
        public function save()   { return Principio_Model_AccountMapper::save($this); }
        public function delete() { return Principio_Model_AccountMapper::delete($this); }
    }
?>